/**
 * Copyright 2014 wasu.com
 *
 *
 * Create on 2015-3-16 下午6:26:44
 */
package stc.skymobi.demo.test;

import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

/**
 * @author <a href="mailto:caoxiaojian@wasu.com>xiaojian.cao</a>
 * 
 */
public class MailSender {

	/**
	 * @param args
	 * @throws EmailException
	 */
	public static void main(String[] args) throws EmailException {
		SimpleEmail email = new SimpleEmail();
		//email.setTLS(true); //是否TLS校验，，某些邮箱需要TLS安全校验，同理有SSL校验
		email.setDebug(true);
		email.setSSLCheckServerIdentity(true);
		email.setStartTLSEnabled(true);
		email.setSmtpPort(465);
		email.setHostName("email.bsoft.com.cn");
		email.setAuthenticator(new DefaultAuthenticator("mailtest@bsoft.com.cn", "Mail+0316"));

		email.setFrom("mailtest@bsoft.com.cn"); // 发送方,这里可以写多个
		email.addTo("mailtest@bsoft.com.cn");
		email.setCharset("GB2312");
		email.setSubject("标题哦"); // 标题
		email.setMsg("测试测试内容，请查阅！！！");// 内容
		email.send();
		System.out.println("发送成功");

	}
}
